<template>
    <iframe :height="height" :width="width" :src="frameSrc" frameborder="0"></iframe>
</template>

<script>
import MForm from '../js/MForm'
import FormBase from "../js/FormBase";

export default {
    name: "MIFrame",
    mixins: [MForm,FormBase],
    props:{
        height:{
            type:String,
            default: "300px"
        },
        width:{
            type:String,
            default:"100%"
        }
    },
    data(){
        return{
            frameSrc:""
        }
    },
    created(){
        let vm=this.formVm
        this.handSrc(vm);
    },
    methods:{
        /**
         * 处理IFRAME链接地址。
         */
        handSrc(vm){
            let reg=/\{\{\s*data\.(.*?)\s*\}\}/ig;
            let template=this.metadata.control.src;
            if (!template){
                this.frameSrc=''
                return;
            }
            let src=template.replace(reg,function(arg1,arg2){
                return vm.data[arg2]	;
            });
            this.frameSrc=src;
        }
    },



}
</script>
